package mvc.models.proxys
{
	import mvc.Notifications;
	
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.proxy.Proxy;
	
	import xl.net.HttpCall;
	
	/**
	 * 用户信息代理
	 * @author XiLing
	 */
	public class ProxyUser extends Proxy implements IProxy
	{
		private static var _instance:ProxyUser;
		public static const NAME:String = "ProxyUser";
		
		public function ProxyUser(proxyName:String=null, data:Object=null)
		{
			super(proxyName, data);
		}
		
		public static function getInstance():ProxyUser
		{
			if(!_instance)
				_instance = new ProxyUser();
			return _instance;
		}
		
		override public function getProxyName():String
		{
			return NAME;
		}
		
		public function login(_username:String,_password:String):void
		{
			HttpCall.yiiCall("site","login",function(_data:Object):void{
				if(!_data)
				{
					sendNotification(Notifications.MEDIATOR_LOGIN_SUCCESS);
				}
			},{'LoginForm[username]':_username,'LoginForm[password]':_password},function($data:Object):void{
				sendNotification(Notifications.MEDIATOR_LOGIN_ERROR,$data);
			});
		}
	}
}